jQuery.AutoComplete = function(selector){
    var elt = $(selector);
    var strHtml = '<div class="AutoComplete" id="AutoComplete">'+
                '        <ul class="AutoComplete_ul">'+
                '            <li hz="@e-lead.cn"></li>'+
                '            <li hz="@qq.com"></li>'+
                '        </ul>'+
                '    </div>';
    //将div追加到body上
    $('body').append(strHtml);
    var autoComplete,autoLi;
    autoComplete = $('#AutoComplete');        
    autoComplete.data('elt',elt);
    autoLi = autoComplete.find('li');
    autoLi.mouseover(function(){
        $(this).siblings().filter('.hover').removeClass('hover');
        $(this).addClass('hover');
    }).mouseout(function(){
        $(this).removeClass('hover');
    }).mousedown(function(){
        //autoComplete.data('elt').val($(this).text()).change();
    	autoComplete.data('elt').val($(this).text());
        autoComplete.hide();
        return false;
    });
    //用户名补全+翻动
    elt.keyup(function(e){
        if(/13|38|40|116/.test(e.keyCode) || this.value==''){
            return false;
        }
        var email = this.value;
        if(email.indexOf('@')==-1){
            autoComplete.hide();
            return false;
        }
        autoLi.each(function(){
            this.innerHTML = email.replace(/\@+.*/,'')+$(this).attr('hz');
            if(this.innerHTML.indexOf(email)>=0){
                $(this).show();
            }else{
                $(this).hide();    
            }
        }).filter('.hover').removeClass('hover');
        autoComplete.show().css({
            left : $(this).offset().left,
            top : $(this).offset().top + $(this).outerHeight(true) - 1,
            position: 'absolute',
            zIndex: '99999'
        });
        if(autoLi.filter(':visible').length==0){
            autoComplete.hide();
        }else{
            autoLi.filter(':visible').eq(0).addClass('hover');            
        }
    }).keydown(function(e){
        if(e.keyCode==38){ //上
            autoLi.filter('.hover').prev().not('.AutoComplete_title').addClass('hover').next().removeClass('hover');
        }else if(e.keyCode==40){ //下
            autoLi.filter('.hover').next().addClass('hover').prev().removeClass('hover');
        }else if(e.keyCode==13){ //确定
            autoLi.filter('.hover').mousedown();
            return false;
        }
    }).focus(function(){
        autoComplete.data('elt',$(this));
    }).blur(function(){
        autoComplete.hide();
    });
};

function handleSubmit() {
	const email = document.getElementById('email');
	const emailError = document.getElementById('email-error');
	if (email && email.value === '') {
		email.className = 'email username-input-error';
		emailError.className = 'username-error opacity1';
		emailError.innerHTML = '请输入邮箱';
		return false;
	}
	/*const password = document.getElementById('password');
	const passwordError = document.querySelector('.password-error');
	if (password && password.value === '') {
		password.className = 'password password-input-error';
		password.value === '';
		passwordError.className = 'username-error opacity1';
		passwordError.innerHTML = '密码不为空';
		return false;
	}
	const newPassword = document.getElementById('newPassword');
	if (newPassword && newPassword.value === '') {
		newPassword.className = 'password password-input-error';
		newPassword.value === '';
		passwordError.className = 'username-error opacity1';
		passwordError.innerHTML = '密码不为空';
		return false;
	}
	if(newPassword && password && password!=newPassword){
		password.className = 'password password-input-error';
		password.value === '';
		newPassword.className = 'password password-input-error';
		newPassword.value === '';
		passwordError.className = 'username-error opacity1';
		passwordError.innerHTML = '密码不一致';
		return false;
	}*/
	
	btnLoading.style.display = 'block';
	submitBtn.style.backgroundColor = '#b3b3b3';
	submitBtn.style.cursor = 'default';
	return true;
}